package cn.kgc.springcloud.controller;

import cn.kgc.springcloud.client.OrderClient;
import cn.kgc.springcloud.entity.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: 课工场
 * @Version: v1.0  2023/2/17
 * @Description:
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private OrderClient orderClient;

    @RequestMapping("test1")
    public String test01(){

        String info = orderClient.test01(); // http://ORDERSERVICE/order/test1
        return  "userService ok" +info;
    }

    @RequestMapping("test2")
    public String findOrder(Integer id){

        System.out.println(" saveOrder () id = " + id);

        String info = orderClient.test02(id); // http://ORDERSERVICE/order/test02

        return  "userService ok" +info;
    }


    @RequestMapping("test3")
    public String test03(Integer id){
        System.out.println("test03() id = " + id);
        String info = orderClient.test03(id); // http://ORDERSERVICE/order/test3/12
        return  "userService ok" +info;
    }

    @RequestMapping("test4")
    public String test04(Order order){ // http://localhost:8506/user/test4?id=10&name=aa

        System.out.println("order = " + order);

        String s = orderClient.test04(order);
        return  "userService ok"+s;
    }

    @RequestMapping("test5")
    public String test05(Integer id){ // json -> object  Order

        Order order = orderClient.test05(id);
        System.out.println("order = " + order);
        return  "userService ok"+order;
    }

}
